//
//  CellBottomView.swift
//  weibo
//
//  Created by yellow on 15/10/20.
//  Copyright © 2015年 yellow. All rights reserved.
//

import UIKit

/// 底部视图为 平分宽度的转发，评论，赞 按钮
class CellBottomView: UIView {
    
    //懒加载控件
    
    //转发
    private lazy var relayWeiboBtn:UIButton = UIButton(title: "转发", color: UIColor.darkGrayColor(), leftImageName: "timeline_icon_retweet", fontSize: 12)
    
    
    //评论
    private lazy var commentBtn:UIButton = UIButton(title: "评论", color: UIColor.darkGrayColor(), leftImageName: "timeline_icon_comment", fontSize: 12)
    
    //点赞
    private lazy var likeBtn:UIButton = UIButton(title: "点赞", color: UIColor.darkGrayColor(), leftImageName: "timeline_icon_unlike", fontSize: 12)
    
    //分割线
    private lazy var separatorLine1:UIView = {
        let line = UIView()
        line.backgroundColor = UIColor.darkGrayColor()
        return line
    }()
    
    private lazy var separatorLine2:UIView = {
        let line = UIView()
        line.backgroundColor = UIColor.darkGrayColor()
        return line
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        backgroundColor = UIColor(white: 0.8, alpha: 0.6)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //界面设置
    func setUI(){
        addSubview(relayWeiboBtn)
        addSubview(separatorLine1)//分割线
        addSubview(commentBtn)
        addSubview(separatorLine2)//分割线
        addSubview(likeBtn)
        
        //自动布局,3个等宽按钮，3个等宽，在设置最右边一个对齐右边，就可以平分3个按钮了
        relayWeiboBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(relayWeiboBtn.snp_top)
            make.left.equalTo(relayWeiboBtn.snp_right)
            make.width.equalTo(relayWeiboBtn.snp_width)
            make.bottom.equalTo(relayWeiboBtn.snp_bottom)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentBtn.snp_top)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
            make.bottom.equalTo(commentBtn.snp_bottom)
            make.right.equalTo(self.snp_right)
        }
        
        separatorLine1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(relayWeiboBtn.snp_centerY)
            make.left.equalTo(relayWeiboBtn.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(relayWeiboBtn.snp_height).multipliedBy(0.5)
        }
        
        separatorLine2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(commentBtn.snp_centerY)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(0.5)
            make.height.equalTo(commentBtn.snp_height).multipliedBy(0.5)
        }
    }
    
    
}
